package com.ego.product.po;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.ego.common.to.SkuEsTo;
import com.ego.product.vo.spu.BaseAttr;
import lombok.Data;

/**
 * @program: ego
 * @description spu属性值
 * @author KamTang
 * @date 2022-11-13 12:56:14
 */
@Data
@TableName("pms_product_attr_value")
public class ProductAttrValue implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@TableId
	private Long id;
	/**
	 * 商品id
	 */
	private Long spuId;
	/**
	 * 属性id
	 */
	private Long attrId;
	/**
	 * 属性名
	 */
	private String attrName;
	/**
	 * 属性值
	 */
	private String attrValue;
	/**
	 * 顺序
	 */
	private Integer attrSort;
	/**
	 * 快速展示【是否展示在介绍上；0-否 1-是】
	 */
	private Integer quickShow;

	public static ProductAttrValue build(BaseAttr baseAttr, Attr attr, SpuInfo spuInfo) {
		ProductAttrValue entity = new ProductAttrValue();
		entity.setAttrId(baseAttr.getAttrId());
		entity.setAttrName(attr.getAttrName());
		entity.setAttrValue(baseAttr.getAttrValues());
		entity.setQuickShow(baseAttr.getShowDesc());
		entity.setSpuId(spuInfo.getId());
		return entity;
	}

	public SkuEsTo.Attrs fill() {
		return BeanUtil.copyProperties(this, SkuEsTo.Attrs.class);
	}
}
